#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
    int year = 0;
    int month = 0;
    int day = 0;
    int sum = 0;
    int a = 31;
    int b = 30;
    int c = 28;
    scanf("%d", &year);
    if ((year % 4 == 0 && year % 100) || year % 400 == 0)
    {
        c = 29;
    }
    scanf("%d", &month);
    switch (month)
    {
    case 12: sum += b;
    case 11: sum += a;
    case 10: sum += b;
    case 9: sum += a;
    case 8: sum += a;
    case 7: sum += b;
    case 6: sum += a;
    case 5: sum += b;
    case 4: sum += a;
    case 3: sum += c;
    case 2: sum += a;
        break;
    default: break;
    }
    scanf("%d", &day);
    sum += day;
    printf("%d", sum);
    return 0;
}